package com.kylin.core.commodity.web.facade.impl;

import com.kylin.commodity.api.dto.req.NewCommodityReqDTO;
import com.kylin.commodity.api.dto.req.QueryCommodityReqDTO;
import com.kylin.commodity.api.dto.resp.CommentRespDTO;
import com.kylin.commodity.api.dto.resp.CommodityRespDTO;
import com.kylin.commodity.api.web.facade.CommodityManageFacade;
import com.kylin.core.commodity.query.handler.CommodityTranslator;
import com.kylin.domain.authority.command.CreateCommodityCommand;
import com.kylin.domain.commodity.provider.CommodityProvider;
import com.kylin.shared.common.anno.ArgsValid;
import com.kylin.shared.common.Pagination;
import com.kylin.shared.common.ResponseWrapper;
import com.kylin.shared.id.impl.SnowflakeIdFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * 管理平台商品功能实现
 * @author Damon S.
 * @version v1.0.1
 * @date {YEAR}年{MONTH}月{DAY}日 {TIME}
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = "商品管理平台")
public class CommodityManageFacadeImpl implements CommodityManageFacade {

    private final CommodityProvider provider;
    private final CommodityTranslator translator;

    @Override
    @ArgsValid
    @ApiOperation(value = "获取商品列表", notes = "分页返回商品(信息精简版)，每页默认10条")
    public ResponseWrapper<Boolean> newCommodity(NewCommodityReqDTO newCommodityReqDTO) {
        Long commodityId = provider.createCommodity(
                CreateCommodityCommand.builder()
                        .commodityId(SnowflakeIdFactory.instance().nextId())
                        .name(newCommodityReqDTO.getName())
                        .subtitle(newCommodityReqDTO.getSubtitle())
                        .code(newCommodityReqDTO.getCode())
                        .coverUrl(newCommodityReqDTO.getCoverUrl())
                        .inventory(newCommodityReqDTO.getInventory())
                        .price(newCommodityReqDTO.getPrice())
                        .createdBy(10000L)
                        .merchantId(10000L)
                        .albumVO(new ArrayList<>())
                        .description(newCommodityReqDTO.getDescription())
                        .build()
        );
        return new ResponseWrapper<>(commodityId > 0);
    }

    @Override
    @ArgsValid
    @ApiOperation(value = "获取商品列表", notes = "分页返回商品(信息精简版)，每页默认10条")
    public ResponseWrapper<Pagination<CommodityRespDTO>> findCommodities(QueryCommodityReqDTO queryCommodityReqDTO) {
        return null;
    }

    @Override
    @ApiOperation(value = "获取商品列表", notes = "分页返回商品(信息精简版)，每页默认10条")
    public ResponseWrapper<CommodityRespDTO> findCommodityById(Long commodityId) {
        return null;
    }

    @Override
    @ApiOperation(value = "获取商品列表", notes = "分页返回商品(信息精简版)，每页默认10条")
    public ResponseWrapper<Pagination<CommentRespDTO>> findCommentsByCommodityId(Long commodityId) {
        return null;
    }

    @Override
    @ApiOperation(value = "获取商品列表", notes = "分页返回商品(信息精简版)，每页默认10条")
    public ResponseWrapper<Boolean> pass(Long commodityId) {
        return null;
    }

    @Override
    @ApiOperation(value = "获取商品列表", notes = "分页返回商品(信息精简版)，每页默认10条")
    public ResponseWrapper<Boolean> reject(Long commodityId) {
        return null;
    }
}
